package com.prs.crm.action.assets;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;

import com.prs.crm.domain.assets.ZhejiuScheme;
import com.prs.crm.service.assets.ZhejiuSchemeService;

public class ZhejiuSchemeAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private ZhejiuScheme zhejiuScheme;
	private ZhejiuSchemeService zhejiuSchemeService;
	private String serCode;

	public String getSerCode() {
		return serCode;
	}
	public void setSerCode(String serCode) {
		this.serCode = serCode;
	}
	public ZhejiuScheme getZhejiuScheme() {
		return zhejiuScheme;
	}
	public void setZhejiuScheme(ZhejiuScheme zhejiuScheme) {
		this.zhejiuScheme = zhejiuScheme;
	}
	public ZhejiuSchemeService getZhejiuSchemeService() {
		return zhejiuSchemeService;
	}
	public void setZhejiuSchemeService(ZhejiuSchemeService zhejiuSchemeService) {
		this.zhejiuSchemeService = zhejiuSchemeService;
	}
	@Action("listAssetsZhejiu")
	public String listAssetsZhejiu(){
		return SUCCESS;
	}
	
	@Action("listAssetsZhejius")
	public String listAssetsZhejius(){
		this.zhejiuScheme=this.getZhejiuSchemeService().getZhejiuScheme(serCode);
		return SUCCESS;
	}
	@Action(value="saveZhejiuScheme",results={
			@Result(name="success",type="redirect",location="listAssetsZhejius?serCode=${zhejiuScheme.getType()}"),
			@Result(name="error",type="chain",location="listAssetsZhejius?serCode=${zhejiuScheme.getType()}")
	})
	public String saveZhejiuScheme(){
		ZhejiuScheme zjs=this.getZhejiuSchemeService().getZhejiuScheme("zj01");
		if (zjs==null) {
			zjs=new ZhejiuScheme();
			zjs.setType("zj01");
			zjs.setMonth(zhejiuScheme.getMonth());
			zjs.setShijian(zhejiuScheme.getShijian());
			zjs.setTime(zhejiuScheme.getTime());
			zjs.setYear(zhejiuScheme.getYear());
			zjs.setZhejiuShijian(zhejiuScheme.getZhejiuShijian());
			zjs.setZhejiuWay(zhejiuScheme.getZhejiuWay());
			this.getZhejiuSchemeService().save(zjs);
		}else{
			this.getZhejiuSchemeService().submit(zjs);
		}
		zhejiuScheme=zjs;
		return SUCCESS;
	}
}
